﻿using System.Threading.Tasks;
using Loong.Dependency;

namespace Loong.Auditing
{
    public class AuditingStore : IAuditingStore, ITransientDependency
    {
        private readonly EfCoreDbAccessor _dbAccessor;

        public AuditingStore(EfCoreDbAccessor auditLogDbAccessor)
        {
            _dbAccessor = auditLogDbAccessor;
        }

        public async Task SaveAsync(AuditInfo auditInfo)
        {
            var auditLog = AuditLog.FromAuditInfo(auditInfo);
            await _dbAccessor.Context.AuditLogs.AddAsync(auditLog);
        }
    }
}
